## Replicate Table A10 Average Treatment Effects in Different Cutoff Points in the Appendix
rm(list = ls())
library(dplyr)
library(foreign)
rawdata<- read_csv("/Users/victorxu/Desktop/side project/military alliance /research and politics/data replication/raw data copy.csv")

## SET the dataset *d1* as response time between 5 to 80 minutes

d1<- rawdata %>%
  filter(Duration..in.seconds. > 300 & Duration..in.seconds. < 3000) %>%
  glimpse()

## recode the variable

## recode approval rate as binary variable 

d1$biatti<- d1$X7attitude
d1$biatti[d1$X7attitude>=5 & d1$X7attitude <=7]<- 1 ## approve 
d1$biatti[d1$X7attitude>=1 & d1$X7attitude<=4]<- 0 ##disapprove
table(d1$biatti)
## recode the treatment

d1$tr1<- NA
d1$tr1[d1$treat==6]<- 0 ## control 
d1$tr1[d1$treat==1]<- 1 ## large casualties
table(d1$tr1)
table(d1$treat)

d1$tr2<-NA
d1$tr2[d1$treat==6]<- 0 ## control 
d1$tr2[d1$treat==2]<- 1 ## low possbility to win
table(d1$tr2)


d1$tr3<-NA
d1$tr3[d1$treat==6]<- 0 ## control 
d1$tr3[d1$treat==5]<- 1 ## economic impact
table(d1$tr3)

d1$tr4<-NA
d1$tr4[d1$treat==6]<- 0 ## control 
d1$tr4[d1$treat==3]<- 1 ## UN
table(d1$tr4)


d1$tr5<-NA
d1$tr5[d1$treat==6]<- 0 ## control 
d1$tr5[d1$treat==4]<- 1 ## economic sanctions
table(d1$tr5)


## treatment 1 large casualties and control group 

t.test(biatti~tr1,data=d1) ## p=0.02

## treatment 2 low prospect of victory and control 

t.test(biatti~tr2,data=d1) ## p=0.09

## treatment 3 economic impact and control

t.test(biatti~tr3,data=d1) ## p=0.37

## treatment 4 UN mediation and control 
t.test(biatti~tr4,data=d1) ## p=0.27

## treatment 5 economic sanctions and control 

t.test(biatti~tr5,data=d1) ## p=0.19

## RESET the dataset *d1* as response time between 5 to 60 minutes
rm(list = ls())

rawdata<- read_csv("/Users/victorxu/Desktop/side project/military alliance /research and politics/data replication/raw data copy.csv")


d1<- rawdata %>%
  filter(Duration..in.seconds. > 300 & Duration..in.seconds. < 3600) %>%
  glimpse()

## recode the variable

## recode approval rate as binary variable 

d1$biatti<- d1$X7attitude
d1$biatti[d1$X7attitude>=5 & d1$X7attitude <=7]<- 1 ## approve 
d1$biatti[d1$X7attitude>=1 & d1$X7attitude<=4]<- 0 ##disapprove
table(d1$biatti)
## recode the treatment

d1$tr1<- NA
d1$tr1[d1$treat==6]<- 0 ## control 
d1$tr1[d1$treat==1]<- 1 ## large casualties
table(d1$tr1)
table(d1$treat)

d1$tr2<-NA
d1$tr2[d1$treat==6]<- 0 ## control 
d1$tr2[d1$treat==2]<- 1 ## low possbility to win
table(d1$tr2)


d1$tr3<-NA
d1$tr3[d1$treat==6]<- 0 ## control 
d1$tr3[d1$treat==5]<- 1 ## economic impact
table(d1$tr3)

d1$tr4<-NA
d1$tr4[d1$treat==6]<- 0 ## control 
d1$tr4[d1$treat==3]<- 1 ## UN
table(d1$tr4)


d1$tr5<-NA
d1$tr5[d1$treat==6]<- 0 ## control 
d1$tr5[d1$treat==4]<- 1 ## economic sanctions
table(d1$tr5)


## treatment 1 large casualties and control group 

t.test(biatti~tr1,data=d1) ## p=0.018

## treatment 2 low prospect of victory and control 

t.test(biatti~tr2,data=d1) ## p=0.07

## treatment 3 economic impact and control

t.test(biatti~tr3,data=d1) ## p=0.44

## treatment 4 UN mediation and control 
t.test(biatti~tr4,data=d1) ## p=0.23

## treatment 5 economic sanctions and control 

t.test(biatti~tr5,data=d1) ## p=0.17

## RESET the dataset *d1* as response time between 10 to 40 minutes
rm(list = ls())

rawdata<- read_csv("/Users/victorxu/Desktop/side project/military alliance /research and politics/data replication/raw data copy.csv")


d1<- rawdata %>%
  filter(Duration..in.seconds. > 600 & Duration..in.seconds. < 2400) %>%
  glimpse()

## recode the variable

## recode approval rate as binary variable 

d1$biatti<- d1$X7attitude
d1$biatti[d1$X7attitude>=5 & d1$X7attitude <=7]<- 1 ## approve 
d1$biatti[d1$X7attitude>=1 & d1$X7attitude<=4]<- 0 ##disapprove
table(d1$biatti)
## recode the treatment

d1$tr1<- NA
d1$tr1[d1$treat==6]<- 0 ## control 
d1$tr1[d1$treat==1]<- 1 ## large casualties
table(d1$tr1)
table(d1$treat)

d1$tr2<-NA
d1$tr2[d1$treat==6]<- 0 ## control 
d1$tr2[d1$treat==2]<- 1 ## low possbility to win
table(d1$tr2)


d1$tr3<-NA
d1$tr3[d1$treat==6]<- 0 ## control 
d1$tr3[d1$treat==5]<- 1 ## economic impact
table(d1$tr3)

d1$tr4<-NA
d1$tr4[d1$treat==6]<- 0 ## control 
d1$tr4[d1$treat==3]<- 1 ## UN
table(d1$tr4)


d1$tr5<-NA
d1$tr5[d1$treat==6]<- 0 ## control 
d1$tr5[d1$treat==4]<- 1 ## economic sanctions
table(d1$tr5)


## treatment 1 large casualties and control group 

t.test(biatti~tr1,data=d1) ## p=0.032

## treatment 2 low prospect of victory and control 

t.test(biatti~tr2,data=d1) ## p=0.07

## treatment 3 economic impact and control

t.test(biatti~tr3,data=d1) ## p=0.33

## treatment 4 UN mediation and control 
t.test(biatti~tr4,data=d1) ## p=0.29

## treatment 5 economic sanctions and control 

t.test(biatti~tr5,data=d1) ## p=0.25
